---
description:
  GraphQL Inspector Audit Documents - Audit your documents for useful metrics such as query depth,
  directive count and alias count.
---

import { Callout } from '@theguild/components'

# Audit (Documents)

Audit your documents for useful metrics such as query depth, directive count and alias count. This
is useful if you want to introduce security rules on your GraphQL server (e.g. via
[`graphql-armor`](https://github.com/Escape-Technologies/graphql-armor)) and need to figure out the
values for doing so.

## Audit - Usage

Run the following command:

```sh
graphql-inspector audit DOCUMENTS
```

## Arguments

- [`DOCUMENTS`](../api/documents) - a glob pattern that points to GraphQL Documents / Operations

## Flags

- `-d, --detail` - Print statistics for each single GraphQL operation (default: `false`)
- `--complexityScalarCost` - The cost of a scalar field for calculating the complexity score
  (default: `1`)
- `--complexityObjectCost` - The cost of an object field for calculating the complexity score
  (default: `2`)
- `--complexityDepthCostFactor` - The cost factor of a field per depth level for calculating the
  complexity score (default: `1.5`)

## Output

A list of metrics including the maximum depth limit, maximum alias count and maximum directive
count.

This process does not fail, as it is mainly for showing useful information. In case you want to
enforce a certain query deth, directive count or alias count limit check the
[`--maxDepth`, `--maxAliasCount` and `--maxDirectiveCount` flags in the Validate Documents](./validate)
documentation.

## Example

```sh
graphql-inspector audit './documents/document.graphql'
```

<Callout type="warning">Make sure to wrap the document in quotes.</Callout>

### Example - Glob Pattern

```sh
graphql-inspector audit './documents/*.graphql'
```

<Callout type="info">
  Make sure to wrap the glob pattern in quotes, otherwise the glob pattern will be expanded by your
</Callout>

<Callout type="warning">Glob patterns are not supported on GitHub Action and GitHub App.</Callout>
